package study.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.security.interfaces.RSAPrivateCrtKey;

@WebServlet(value = "/two")
public class TwoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        Integer one = (Integer) request.getAttribute("one");

        HttpSession session = request.getSession();

        Integer two = (Integer) session.getAttribute("two");

        //所有全局对象
        ServletContext servletContext = this.getServletContext();

        Integer context = (Integer) servletContext.getAttribute("context");

        response.getWriter().print("one="+one+",two="+two+",context="+context);

        
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
    }
}
